-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add useCallback to avoid unnecessary rerenders of FloatingMessageCounter #54944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add useCallback to avoid unnecessary rerenders of FloatingMessageCounter #54944
Conversation
@hoangzinh Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-01-16.at.17.20.48.movAndroid: mWeb ChromeScreen.Recording.2025-01-10.at.22.59.51.android.chrome.moviOS: NativeScreen.Recording.2025-01-16.at.17.54.27.moviOS: mWeb SafariScreen.Recording.2025-01-16.at.17.33.26.movMacOS: Chrome / SafariScreen.Recording.2025-01-10.at.22.48.55.web.movMacOS: DesktopScreen.Recording.2025-01-10.at.22.57.33.desktop.mov |
Hi @OlimpiaZurek can you add some testing steps in PR description? I think we can put some tests to ensure it still works. Also recordings/screenshots too. |
Hey @hoangzinh ! I added repro steps and recording. |
Looked like we were missing recording @OlimpiaZurek |
Added missing recording ( MacOS: Chrome / Safari) |
how about other platforms? (mWeb/Native/Desktop) @OlimpiaZurek |
@hoangzinh Added recordings for other platforms |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We did not find an internal engineer to review this PR, trying to assign a random engineer to #55001 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
6aa9356
to
c3ec796
Compare
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/jasperhuangg in version: 9.0.89-0 🚀
|
🚀 Deployed to production by https://github.com/yuwenmemon in version: 9.0.89-8 🚀
|
Explanation of Change
Background
The
FloatingMessageCounter
component is used to display the number of unread messages in a chat thread.Problem
It causes unnecessary re-renders when the user switches workspaces or when modals are opened or closed.
Solution
Wrap the
scrollToBottomAndMarkReportAsRead
function in useCallback to ensure it is not recreated on every render. This will prevent unnecessary re-renders during workspace switches, modal interactions, and message updates. Wrapping the function inuseCallback
will ensure it is only recreated when necessary, leading to smoother transitions and more efficient interactions.Fixed Issues
$ #55001
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2025-01-10.at.10.52.51.mov
MacOS: Desktop